package com.qf.utils;

import com.alibaba.fastjson.JSONObject;

import com.qf.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

/**
 * @Author JiaLei Hei
 * @Date 2021/10/25
 */
@Component
public class CatsUserUtils {
    @Autowired
    RedisTemplate redisTemplate;

    public User getUserByToken(String token){
        Boolean aBoolean = redisTemplate.hasKey(token);
        if(!aBoolean){
            return null;
        }
        Object o = redisTemplate.opsForValue().get(token);
        return JSONObject.parseObject(JSONObject.toJSONString(o), User.class);
    }
}
